{{- if hasKey .Values.prometheus.internal "remoteWrite" }}
  {{- if .Values.prometheus.internal.remoteWrite }}
    {{- range .Values.prometheus.internal.remoteWrite }}
      {{- if .spec.basicAuth }}
---
apiVersion: v1
kind: Secret
metadata:
  name: d8-prometheus-remote-write-{{ .name }}
  namespace: d8-monitoring
  {{- include "helm_lib_module_labels" (list $ (dict "app" "prometheus")) | nindent 2 }}
type: Opaque
data:
  username: {{ .spec.basicAuth.username | b64enc | quote }}
  password: {{ .spec.basicAuth.password | b64enc | quote }}
      {{- end }}

      {{- if .spec.tlsConfig }}
        {{  if .spec.tlsConfig.ca }}
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: d8-prometheus-remote-write-ca-{{ .name }}
  namespace: d8-monitoring
  {{- include "helm_lib_module_labels" (list $ (dict "app" "prometheus")) | nindent 2 }}
data:
  ca.crt: {{ .spec.tlsConfig.ca | quote }}
        {{- end }}
      {{- end }}
    {{- end }}
  {{- end }}
{{- end }}
